'use strict';
/**
 * 给指定的HTML元素添加class
 * 
 * @param {Element} element 
 * @param {String} className 
 */ 
export function addClass(element, className) { 
    const original = element.className;

    if (original.length === 0) { 
        element.className = className;
        return;
    }

    if (original.match(new RegExp('(^|\\s)' + className + '(\\s|$)'))){
        return;
    }

    element.className = original + ' ' + className;
}